LogicalAnd
逐元素执行逻辑与(Logical AND)运算。
对输入张量的对应元素先进行布尔化判断,再执行逻辑与运算,输出结果为 0 或 1, 并以与输入相同的数据类型返回。
\[\begin{split}\text{output}_i =
\begin{cases}
1, & \text{if } (\text{input0}_i \neq 0) \land (\text{input1}_i \neq 0) \\
0, & \text{otherwise}
\end{cases}\end{split}\]
- 输入:
input0 - 第一个输入张量的数据地址。
input1 - 第二个输入张量的数据地址。
length - 输入张量的总元素数量。
core_mask - 核掩码。
- 输出:
output - 输出张量的数据地址,其大小与
input0、input1相同。
- 支持平台:
FT78NEMT7004
备注
FT78NE 支持的数据类型:fp32, fp64, int8, int16, int32
MT7004 支持的数据类型:fp16, fp32, int16, int32
输入值在参与逻辑运算前会被转换为布尔值(非 0 为 true,0 为 false)
输出结果仅为 0 或 1
共享存储版本:
-
void fp_and_s(float *input0, float *input1, float *output, int length, int core_mask)
-
void dp_and_s(double *input0, double *input1, double *output, int length, int core_mask)
-
void i8_and_s(int8_t *input0, int8_t *input1, int8_t *output, int length, int core_mask)
-
void i16_and_s(int16_t *input0, int16_t *input1, int16_t *output, int length, int core_mask)
-
void i32_and_s(int32_t *input0, int32_t *input1, int32_t *output, int length, int core_mask)
-
void hp_and_s(half *input0, half *input1, half *output, int length, int core_mask)
C调用示例:
1// FT78NE 多核示例
2#include <stdio.h>
3#include <logical_and.h>
4
5int main(int argc, char* argv[]) {
6 float *input0 = (float *)0xA0000000; // input0 在 DDR 空间
7 float *input1 = (float *)0xA0010000; // input1 在 DDR 空间
8 float *output = (float *)0xB0000000; // output 在 DDR 空间
9
10 int length = 4096;
11 int core_mask = 0xff;
12
13 fp_and_s(input0, input1, output, length, core_mask);
14 return 0;
15}
私有存储版本:
-
void fp_and_p(float *input0, float *input1, float *output, int length)
-
void dp_and_p(double *input0, double *input1, double *output, int length)
-
void i8_and_p(int8_t *input0, int8_t *input1, int8_t *output, int length)
-
void i16_and_p(int16_t *input0, int16_t *input1, int16_t *output, int length)
-
void i32_and_p(int32_t *input0, int32_t *input1, int32_t *output, int length)
-
void hp_and_p(half *input0, half *input1, half *output, int length)
C调用示例:
1// MT7004 单核示例
2#include <stdio.h>
3#include <logical_and.h>
4
5int main(int argc, char* argv[]) {
6 half *input0 = (half *)0x10000000; // input0 在 L2 空间
7 half *input1 = (half *)0x10002000; // input1 在 L2 空间
8 half *output = (half *)0x10010000; // output 在 L2 空间
9
10 int length = 1024;
11
12 hp_and_p(input0, input1, output, length);
13 return 0;
14}